// Import some needed modules.
import std.stdio; // Module for input/output on the console
import std.file;  // Module for file i/o
import std.string;

// The "main" function: the program starts here.
void main(char[][] args)
{
  	string searchString;
	
	if (args.length > 1) {
					bool resultIs;

					searchString = cast(string) args[1];

					// Writing empty line
					writeln("Searching ", searchString);
					writeln;					

					auto javaFiles = dirEntries(".","*.{java}", SpanMode.depth);

					foreach(fileSource; javaFiles) {
								//writeln("Now: ",fileSource.name);
								
								foreach(textLine; File(fileSource).byLine()) {
									
									if (indexOf(textLine, searchString) != -1) {

										writeln(">>> ", fileSource.name);
										//writeln("in line: ", textLine);
										resultIs = true;
										break;
									}

								}
					}

					if (!resultIs) writeln("Nothing :(");
	}

	else {
		writeln("Use this as: <program> <argument>");
		writeln("where <argument> is searching string.");
	}
	
}